<template>
	<view class="content">
		<view class="text">交易记录</view>
		<view class="uni-list">
			<view class="uni-list-cell" hover-class="uni-list-cell-hover" v-for="(item,index) in tranflowList" :key="index">
				<view class="uni-media-list">
					<view class="uni-media-list-body">
						<view>{{item.type}} {{item.out}}<label class="money">{{item.amount}}</label></view>
						<view class='getime'>
							{{item.time}}
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				tranflowList: []
			}
		},
		onLoad() {
			this.getttxs()
		},
		methods: {
			getttxs: function() {
				uni.request({
					url: 'http://' + getApp().globalData.mpAddress + '/gettxs',
					method: 'GET',
					data: {
						hash: getApp().globalData.userData['MgxHashID']
					},
					success: res => {
						console.log(res)
						//转成json对象
						//var json = JSON.parse(res.data.Data.res_info);

						// if (res && res.data.Data.list && res.data.Data.list.length > 0) {
						// 	res.data.Data.list.forEach(item => {
						// 		if (item.in.length && item.in.length > 12) {
						// 			item.in = item.in.substring(0, 5) + "***" + item.in.substring(item.in.length - 5);
						// 			item.out = item.out.substring(0, 5) + "***" + item.out.substring(item.out.length - 5);
						// 		}
						// 	});
						// }
						console.log(res.data["units"])
						this.tranflowList = res.data["units"]
					},
					fail: () => {},
					complete: () => {}
				});
			}
		}
	}
</script>

<style>
	.money {
		float: right;
		margin-right: 10px;
	}

	.getime {
		font-size: 12px;
	}
</style>
